package org.example.shoppingmall.service.impl;

import org.example.shoppingmall.dao.OpenDao;
import org.example.shoppingmall.entity.Category;
import org.example.shoppingmall.entity.Goods;
import org.example.shoppingmall.service.OpenService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

public class OpenServiceImpl implements OpenService {
    OpenDao openDao = new OpenDao();

    /**
     * 将所有商品存入List列表
     *
     * @param
     * @return
     */
    @Override
    public List<Goods> goodsDisplay(Integer page_size,Integer page) {
        return openDao.goodsSearch(page_size, page);
    }

    /**
     * 记录商品总数
     * @param
     * @param
     * @return
     */
    @Override
    public Integer goodsCount() {
        return openDao.goodsCount();
    }

    /**
     * 根据类别记录商品数量
     * @param category_id
     * @return
     */
    @Override
    public Integer goodsCountByCategory(Integer category_id) {
        return openDao.goodsCountByCategory(category_id);
    }

    /**
     * 根据关键字记录商品数量
     * @param
     * @return
     */
    @Override
    public Integer goodsCountByKeyword(String keyword) {
        return openDao.goodsCountByKeyword(keyword);
    }

    /**
     * 获取所有类别
     * @return
     */
    @Override
    public List<Category> getAllCategory() {
        return openDao.getAllCategory();
    }

    /**
     * 根据类别获取商品
     * @param categoryId
     * @param page_size
     * @param page
     * @return
     */
    @Override
    public List<Goods> goodsDisplayByCategory(Integer categoryId, Integer page_size, Integer page) {
        return openDao.goodsDisplayByCategory(categoryId,page_size,page);
    }

    /**
     * 根据关键字获取商品
     * @param keyword
     * @param page_size
     * @param page
     * @return
     */
    @Override
    public List<Goods> goodsSearchByKeyword(String keyword,Integer page_size,Integer page) {
        return openDao.goodsSearchByKeyword(keyword,page_size,page);
    }
}
